package com.game.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.game.common.core.domain.entity.SysUser;
import com.game.common.utils.DateUtils;
import com.game.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.game.business.mapper.TOrderDbrRecordMapper;
import com.game.business.domain.TOrderDbrRecord;
import com.game.business.service.ITOrderDbrRecordService;

/**
 * 订单担保人Service业务层处理
 *
 * @author ruoyi
 * @date 2025-10-15
 */
@Service
public class TOrderDbrRecordServiceImpl extends ServiceImpl<TOrderDbrRecordMapper,TOrderDbrRecord>  implements ITOrderDbrRecordService
{
    @Autowired
    private TOrderDbrRecordMapper tOrderDbrRecordMapper;

    @Autowired
    private ISysUserService sysUserService;


    /**
     * 查询订单担保人
     *
     * @param id 订单担保人主键
     * @return 订单担保人
     */
    @Override
    public TOrderDbrRecord selectTOrderDbrRecordById(String id)
    {
        return tOrderDbrRecordMapper.selectTOrderDbrRecordById(id);
    }

    /**
     * 查询订单担保人列表
     *
     * @param tOrderDbrRecord 订单担保人
     * @return 订单担保人
     */
    @Override
    public List<TOrderDbrRecord> selectTOrderDbrRecordList(TOrderDbrRecord tOrderDbrRecord)
    {
        List<TOrderDbrRecord> tOrderDbrRecords = tOrderDbrRecordMapper.selectTOrderDbrRecordList(tOrderDbrRecord);
        for (TOrderDbrRecord tOrderDbrRecord1 : tOrderDbrRecords) {
            SysUser sysUser1 = sysUserService.selectUserById(Long.parseLong(tOrderDbrRecord1.getDbrUserId()));
            tOrderDbrRecord1.setDbrUser(sysUser1);
        }
        return tOrderDbrRecords;
    }

    /**
     * 新增订单担保人
     *
     * @param tOrderDbrRecord 订单担保人
     * @return 结果
     */
    @Override
    public int insertTOrderDbrRecord(TOrderDbrRecord tOrderDbrRecord)
    {
                tOrderDbrRecord.setCreateTime(DateUtils.getNowDate());
            return tOrderDbrRecordMapper.insertTOrderDbrRecord(tOrderDbrRecord);
    }

    /**
     * 修改订单担保人
     *
     * @param tOrderDbrRecord 订单担保人
     * @return 结果
     */
    @Override
    public int updateTOrderDbrRecord(TOrderDbrRecord tOrderDbrRecord)
    {
                tOrderDbrRecord.setUpdateTime(DateUtils.getNowDate());
        return tOrderDbrRecordMapper.updateTOrderDbrRecord(tOrderDbrRecord);
    }

    /**
     * 批量删除订单担保人
     *
     * @param ids 需要删除的订单担保人主键
     * @return 结果
     */
    @Override
    public int deleteTOrderDbrRecordByIds(String[] ids)
    {
        return tOrderDbrRecordMapper.deleteTOrderDbrRecordByIds(ids);
    }

    /**
     * 删除订单担保人信息
     *
     * @param id 订单担保人主键
     * @return 结果
     */
    @Override
    public int deleteTOrderDbrRecordById(String id)
    {
        return tOrderDbrRecordMapper.deleteTOrderDbrRecordById(id);
    }
}
